package org.bot.plugin.web.event;

import org.bot.api.event.DataStorage;
import org.bot.api.event.EventName;
import org.bot.api.event.Events;
import org.bot.api.flow.FlowNode;
import org.bot.http.client.HttpTool;
import org.bot.plugin.web.util.CookieBuild;
import org.bot.plugin.web.util.WebApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 沧月
 * @create 0011 2023/10/11 15:27
 * @description <站内下载（附带cookie）>
 */

@Component
@EventName("站内下载")
public class WebSiteDownload implements Events {

    @Autowired
    WebApi webApi;

    @Override
    public Object exec(FlowNode note, DataStorage data) {
        return HttpTool.downloadFile(data.get(note.getDataIndex()).toString(),
                CookieBuild.build(webApi.getWebDriver(note)));
    }

}
